
from selenium import webdriver
import time

# driver = webdriver.Chrome()

# driver.get('https://www.baidu.com/')

# time.sleep(2)
# 隐式等待
# driver.implicitly_wait(10)
# 页面元素没有加载出来会等待10秒
# driver.find_element_by_id('kwsss').send_keys('python')

# 显示等待
# 显示等待是表明某个条件成立后才执行获取元素的操作
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get("https://www.baidu.com/")
# driver.get("https://www.douban.com/")


try:
    element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "kw"))
        # EC.presence_of_element_located(driver.find_element_by_id('kw'))
    )
    time.sleep(2)
finally:
    # driver.quit()
    pass


